<?php

function pdfEncrypt ($origFile, $password, $destFile){



$pdf = new FPDI_Protection('P', 'mm', 'A4');
// set the format of the destinaton file, in our case 6×9 inch
$pdf->FPDF('P', 'in', array('6','9'));

//calculate the number of pages from the original document
$pagecount = $pdf->setSourceFile($origFile);

// copy all pages from the old unprotected pdf in the new one
for ($loop = 1; $loop <= $pagecount; $loop++) {
    $tplidx = $pdf->importPage($loop);
    $pdf->addPage();
    $pdf->useTemplate($tplidx);
}


$pdf->SetProtection(array(),$password);
$pdf->Output($destFile, 'F');

return $destFile;
}



function getEncodedPdf($origen,$destino,$pass,$valores){

$pdf = new PDF();
$pdf->AliasNbPages();
$pdf->AddPage();
$pdf->SetFont('Times','',12);
for($i=1;$i<100;$i++)
	$pdf->Cell(0,10,$valores[$i],0,1);

$pdf->Output($origen,'F');
$password =$pass;
echo "Iniciando<br/>";
pdfEncrypt($origen,$password,$destino);
echo "fin<br/>";    
}



?>
